package com.rtp2p.rtcoresdkdemo.add.menu

import androidx.fragment.app.viewModels
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import com.rtp2p.rtcoresdkdemo.R
import com.rtp2p.rtcoresdkdemo.add.AddViewModel

import com.rtp2p.rtcoresdkdemo.base.BaseFragment
import com.rtp2p.rtcoresdkdemo.databinding.AddMenuFragmentBinding

class AddMenuFragment : BaseFragment() {
    private val addViewModel: AddViewModel by viewModels({ requireActivity() })
    override fun initWorkspaceAction(inflater: LayoutInflater, container: ViewGroup?): View {
        val binding = AddMenuFragmentBinding.inflate(layoutInflater)

        binding.btnReturn.setOnClickListener { requireActivity().finish() }
        binding.btnBindingDevice.setOnClickListener {
            startFragment(R.id.action_addMenuFragment_to_addBindingFragment)
        }
        binding.btnBindingApDevice.setOnClickListener {
            addViewModel.updateAddType(AddViewModel.AddType.Ap)
            startFragment(R.id.action_addMenuFragment_to_addConfigWifiFragment)
        }
        binding.btnBindingBleDevice.setOnClickListener {
            addViewModel.updateAddType(AddViewModel.AddType.Ble)
            startFragment(R.id.action_addMenuFragment_to_addConfigWifiFragment)
        }
        binding.btnBindingLanDevice.setOnClickListener {
            startFragment(R.id.action_addMenuFragment_to_addBindingLanFragment)
        }
        return binding.root
    }

}